package com.cet.designpatterns.principle.singleresponsibility;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-08-25 16:27
 **/
public class SingleResponsibility03 {
    public static void main(String[] args) {
        Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.run("汽车");
        vehicle2.runAir("飞机");
        vehicle2.runWater("轮船");
    }
}

/**
 * 方式3
 * 1、没有对原来的类做大的修改，只是增加了方法
 * 2、虽然没有在类级别上遵守单一职责原则，但在方法级别上遵守单一职责原则
 */

class Vehicle2{
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路上行驶……");
    }

    public void runAir(String vehicle) {
        System.out.println(vehicle + "在空中飞行……");
    }

    public void runWater(String vehicle) {
        System.out.println(vehicle + "在水面上行驶……");
    }
}
